//
//  AqiViewController.m
//  WeatherGuide
//
//  Created by lanou3g on 15/12/22.
//  Copyright © 2015年 李明. All rights reserved.
//

#import "AqiViewController.h"
#import "Weather.h"
#import "Aqi.h"
#import "AqiView.h"

@interface AqiViewController ()

@property (strong, nonatomic) IBOutlet AqiView *rootView;
@property (strong, nonatomic) IBOutlet UILabel *aqiLabel;

@property (strong, nonatomic) IBOutlet UILabel *cityLabel;

@property (strong, nonatomic) IBOutlet UILabel *qltyLabel;
@property (strong, nonatomic) IBOutlet UILabel *pm10Label;
@property (strong, nonatomic) IBOutlet UILabel *pm25Label;
@property (strong, nonatomic) IBOutlet UILabel *NO2Label;
@property (strong, nonatomic) IBOutlet UILabel *SO2Label;


@end

@implementation AqiViewController


- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super initWithCoder:coder];
    if (self) {
        [self setWeather:self.weather];
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self setWeather:self.weather];
   
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



- (void)setWeather:(Weather *)weather
{
    Aqi *aqi = weather.aqi;
   
    if (aqi.aqi.length != 0) {
        self.aqiLabel.text = aqi.aqi;
    }

    if (aqi.aqi.length != 0) {
        self.aqiLabel.text = aqi.aqi;
    }
    if (weather.city.length != 0) {
        self.cityLabel.text = weather.city;
    }
    if (aqi.qlty.length != 0) {
        self.qltyLabel.text = aqi.qlty;
    }
    if (aqi.pm10.length != 0) {
        self.pm10Label.text = aqi.pm10;
    }
    if (aqi.pm25.length != 0) {
        self.pm25Label.text = aqi.pm25;
    }
    if (aqi.no2.length != 0) {
        self.NO2Label.text = aqi.no2;
    }
    if (aqi.so2.length != 0) {
        self.SO2Label.text = aqi.so2;
    }
    
    
    
    
    
    
    
    self.rootView.aqi = aqi;
    
   

}

- (IBAction)backDidClicked:(id)sender {
    [self dismissViewControllerAnimated:YES completion:^{
        ;
    }];
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
